package com.zzl.admin.service.task.impl;

import com.zzl.admin.service.task.TaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

/**
 * Description：定时任务服务接口
 * Created by 朱正磊 on 2019-04-02 22:58
 */
@Slf4j
@Service
public class TaskServiceImpl implements TaskService {

    /**
     * description：定时任务1（每间隔1秒钟执行一次该方法）
     * user 朱正磊
     * time 2019-04-02 22:57
     */
    @Override
    //@Scheduled(fixedDelay = 1000)
    public void goTask1() {
        try {
            Thread.sleep(5000); //睡眠5秒
            log.info("goTask1 " + Thread.currentThread().getName()); //打印当前线程名字
        } catch (Exception e) {
            log.error(e.getMessage());
        }
    }

    /**
     * description：定时任务2（每间隔1秒钟执行一次该方法）
     * user 朱正磊
     * time 2019-04-02 22:57
     */
    @Override
    //@Scheduled(cron = "0/1 * * * * ?")
    public void goTask2() {
        try {
            Thread.sleep(5000); //睡眠5秒
            log.info("goTask2 " + Thread.currentThread().getName()); //打印当前线程名字
        } catch (Exception e) {
            log.error(e.getMessage());
        }
    }

}
